package com.example.myapplication.net

import com.example.myapplication.net.bean.response.BaseResponse
import com.example.myapplication.net.bean.response.InsertFileBean
import com.example.myapplication.net.bean.response.LoginBean
import com.example.myapplication.net.bean.request.*
import okhttp3.MultipartBody
import retrofit2.Call
import retrofit2.http.*


interface ServiceApi {

    /**
     * 获取Key
     */
    @POST("app/sys/getRSAKey")
    fun postGetRSAKey(): Call<BaseResponse<String>>

    /**
     * 登录
     */
    @POST("app/sys/login")
    fun postLoginData(@Body param: BaseRequest<LoginParams>): Call<BaseResponse<LoginBean>>

    //获取上传ID
    @POST("app/rfs/initUpload")
    fun initUpload(@Body param: BaseRequest<EmptyParams>): Call<BaseResponse<String>>

    //校验文件块是否存在
    @POST("app/rfs/checkChunkExist")
    fun checkChunkExist(@Body param: BaseRequest<CheckChunkExistParams>): Call<BaseResponse<Boolean>>

    //文件上传
    @Multipart
    @Streaming
    @POST("app/rfs/chunkUpload")
    fun chunkUpload(
        @Part("hashCode") hashCode: String,
        @Part("index") index: Int,
        @Part("docChunkNumber") docChunkNumber: Int,
        @Part("uploadId") uploadId: String,
        @Part("docSize") docSize: Long,
        @Part("chunkSize") chunkSize: Int,
        @Part("blockSize") blockSize: Int,
        @Part("token") token: String,
        @Part("userId") userId: Int,
        @Part("docName") docName: String,
        @Part file: MultipartBody.Part
    ): Call<BaseResponse<Boolean>>

    /**
     * 文件插入项目
     */
    @POST("app/rfs/insert")
    fun insertFile(@Body param: BaseRequest<InsertFileParams>): Call<BaseResponse<InsertFileBean>>
    /**
     * 文件插入项目
     */
    @POST("app/project/doc/insert")
    fun insertDirFile(@Body param: BaseRequest<InsertFileInDirParams>): Call<BaseResponse<Any>>

}